package main

import (
	"fmt"
	"sync"
	"time"
)

var lock sync.Mutex

func test() {
	lock.Lock() //test函数加上锁后，同一时刻只能被调用一次，后续的调用只能阻塞
	defer lock.Unlock()
	time.Sleep(10 * time.Second)
	fmt.Println("协程执行完毕...")
}

func main() {
	fmt.Println("start...")
	go test()
	time.Sleep(2 * time.Second)
	go test()
	time.Sleep(60 * time.Second)
}
